<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@ page import="com.fengke.portal.config.HostConfig" %>
<%
	HostConfig hostConfig = (HostConfig) request.getSession().getServletContext().getAttribute("hostConfig");
%>
<!DOCTYPE html>
	<head>
		<base href="<%=hostConfig.getPortalHost() %>" />
		<title><%=hostConfig.getWebSiteName() %></title>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<meta name="author" content="BlackFalcon IT Group" />
		<meta name="copyright" content="BlackFalcon IT Group" />
<!-- 		<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script> -->
	</head>
	<body>
		<form id="weixin_return_form" name="weixin_return_form" action="travel/payment/syncTencentNotify.action" method="post" style="display: none;">
			<input type="hidden" id="orderSN" name="orderVO.orderModel.sn" value="<s:property value='orderVO.orderModel.sn' />" /> 
			<input type="hidden" id="return_json" name="return_json" value="" />
			<input type="hidden" id="return_code" name="return_code" value="" />
			<input type="hidden" id="return_desc" name="return_desc" value="" />
			<input type="hidden" id="return_message" name="return_message" value="" />
		</form>
		<script type="text/javascript">
		if (typeof WeixinJSBridge == "undefined"){
			   if( document.addEventListener ){
			       document.addEventListener('WeixinJSBridgeReady', weixinPay, false);
			   }else if (document.attachEvent){
			       document.attachEvent('WeixinJSBridgeReady', weixinPay); 
			       document.attachEvent('onWeixinJSBridgeReady', weixinPay);
			   }
			}else{
				weixinPay();
		}
			
		function weixinPay() {
			var str = window.navigator.userAgent;
			var version = str.substring(8, 11);
			if (version != "5.0") {
				alert("微信浏览器系统版本过低，请将微信升级至5.0以上");
			} else {
				WeixinJSBridge.invoke(
					'getBrandWCPayRequest', {
						"appId" : "<s:property value='wxPayParamMap.appId' />", //公众号名称，由商户传入
						"timeStamp" : "<s:property value='wxPayParamMap.timeStamp' />", //时间戳
						"nonceStr" : "<s:property value='wxPayParamMap.nonceStr' />", //随机串
						"package" : "<s:property value='wxPayParamMap.package' />",//统一支付接口返回的prepay_id 参数值，提交格式如：prepay_id=***
						"signType" : "<s:property value='wxPayParamMap.signType' />", //微信签名方式:sha1
						"paySign" : "<s:property value='wxPayParamMap.paySign' />" //微信签名
					}, function(res) {
						//alert(res);
					    // get_brand_wcpay_request:cancel 用户取消
						// get_brand_wcpay_request:fail 发送失败
						// get_brand_wcpay_request:ok //发送成功
						// WeixinJSBridge.log(res.err_msg);alert(res);
						// alert(res.err_code + res.err_desc);
						// alert(res.err_msg);
						document.getElementById('return_json').value = res;
						document.getElementById('return_code').value = res.err_code;
						document.getElementById('return_message').value = res.err_msg;
						document.getElementById('return_desc').value = res.err_desc;
						document.getElementById('weixin_return_form').submit();
					}
				);
		
			}
		}
		</script>
	</body>
</html>